home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-06-03 | 1.5 KB | 63 lines | [TEXT/IGR0] |
- #include <BringDestToFront>
-
- | CmplxToMagPhase converts a complex wave, presumed to be the result of an FFT,
- | to _Mag and _Phase waves.
- |
- Macro CmplxToMagPhase(w,linlog,phase,phasetype)
- string w
- Prompt w,"Complex data wave:",popup WaveList("*",";","")
- variable linlog= 2
- Prompt linlog,"Magnitude mode:",popup "Linear;dB"
- Variable phase= 1
- Prompt phase,"Phase:",popup "No phase;Phase in radians;Phase in degrees"
- Variable phasetype=1
- Prompt phasetype,"Unwrap phase?",popup,"No;Yes"
- ;
- PauseUpdate; silent 1
-
- string destw=w+"_Mag",phasew= w+"_Phase"
- Variable n= numpnts($w)
-
- Duplicate/O $w $destw
- $destw= r2polar($destw) | If error here, $destw is probably not a complex wave
- | NOTE: depending on your application you may want to un-comment the next line
- | $destw[0] /= 2 | dc is special
- if( phase!=1 )
- Duplicate/O $destw $phasew
- Redimension/R $phasew
- $phasew= imag($destw)
- if( phasetype==2 )
- $phasew[0]= $phasew[1] | try to avoid glitch at dc
- UnWrap 2*Pi,$phasew
- $phasew[0]= 0
- endif
- if(phase==3)
- $phasew *= 180/Pi
- SetScale y,0,0,"deg",$phasew
- else
- SetScale y,0,0,"rad",$phasew
- endif
- endif
- Redimension/R $destw
- if( linlog==2 )
- WaveStats/Q $destw
- $destw= 20*log($destw/V_max)
- SetScale y,0,0,"dB",$destw
- else
- $destw /= n/2
- SetScale y,0,0,"V",$destw
- endif
- BringDestFront(destw)
- if( phase!=1 )
- CheckDisplayed $phasew
- if( !V_Flag )
- Append/R $phasew
- endif
- endif
- if( numpnts($destw) <= 129 )
- Modify mode($destw)=4,marker($destw)=19,msize($destw)=1
- else
- Modify mode($destw)=0
- endif
- end
-